//
//  SCApiTool+user.m
//  ScalperMerchant
//
//  Created by 王云 on 2017/10/9.
//  Copyright © 2017年 WY. All rights reserved.
//

#import "SCApiTool+user.h"

@implementation SCApiTool (user)

#pragma mark 注册
+ (void)ScRegMember_mobile:(NSString *)member_mobile
             member_passwd:(NSString *)member_passwd
                      code:(NSString *)code
                   success:(void(^)(NSDictionary *dic))success
                   failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"member_mobile":member_mobile,
                             @"member_passwd":member_passwd,
                             @"code":code,
                             @"source":@"ios"};
    [SCApiTool ZYPost:@"business/auth/signup"
           parameters:parmes
        netIdentifier:@"business/auth/signup"
             progress:nil
              success:^(ZYJsonData *data) {
                  //wangyun
                  
                  success(data.data);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}
#pragma mark 登录
+ (void)ScLoginMember_mobile:(NSString *)member_mobile
               member_passwd:(NSString *)member_passwd
                     unionid:(NSString *)unionid
                  headimgurl:(NSString *)headimgurl
                    nickname:(NSString *)nickname
                         sex:(NSString *)sex
                     success:(void(^)(NSString *msg))success
                     failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"member_mobile":member_mobile,
                             @"member_passwd":member_passwd,
                             @"unionid":unionid,
                             @"headimgurl":headimgurl,
                             @"nickname":nickname,
                             @"sex":sex};
    [SCApiTool ZYPost:@"business/auth/login"
           parameters:parmes
        netIdentifier:@"business/auth/login"
             progress:nil
              success:^(ZYJsonData *data) {
                  [SCUserTool logIn:[SCUserTool loadUserData:data.data]];
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];

}

#pragma mark 入驻
+ (void)ScJoininStore_name:(NSString *)store_name
               store_phone:(NSString *)store_phone
             store_address:(NSString *)store_address
              coordinate_x:(NSString *)coordinate_x
              coordinate_y:(NSString *)coordinate_y
business_licence_number_elc:(NSString *)business_licence_number_elc
business_licence_id_number_positive:(NSString *)business_licence_id_number_positive
business_licence_id_number_negative:(NSString *)business_licence_id_number_negative
               store_label:(NSString *)store_label
                     bd_id:(NSString *)bd_id
             contacts_name:(NSString *)contacts_name
            contacts_phone:(NSString *)contacts_phone
                     token:(NSString *)token
                   success:(void(^)(NSString *msg))success
                   failure:(void (^)(NSString *errormsg))fail{
    
    NSDictionary *parmes = @{@"store_name":store_name,
                             @"store_phone":store_phone,
                             @"store_address":store_address,
                             @"coordinate_x":coordinate_x,
                             @"coordinate_y":coordinate_y,
                             @"business_licence_number_elc":business_licence_number_elc,
                             @"business_licence_id_number_positive":business_licence_id_number_positive,
                             @"business_licence_id_number_negative":business_licence_id_number_negative,
                             @"store_banner":store_label,
                             @"bd_id":bd_id,
                             @"contacts_name":contacts_name,
                             @"contacts_phone":contacts_phone};
    [SCApiTool ZYPostStore_name:@"business/shopstore/joinin"
                     parameters:parmes
                          token:token
                  netIdentifier:@"business/shopstore/joinin"
                       progress:nil
                        success:^(ZYJsonData *data) {
                            SCUser *user = [SCUserTool loadInfo];
                            user.joinin_state = @"10";
                            [SCUserTool changeData:user];
                            success(data.msg);
                        } failure:^(NSString *msg) {
                             fail(msg);
                        }];
}

#pragma mark 已入驻店铺概要信息
+ (void)ScStoredetailSuccess:(void(^)(NSDictionary *data))success
                     failure:(void (^)(NSString *errormsg))fail{
    [SCApiTool ZYGet:@"business/shopstore/storedetail"
       netIdentifier:@"business/shopstore/storedetail"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
                 
             } failure:^(NSString *msg) {
                  fail(msg);
             }];
}

#pragma mark 我的账单
+ (void)ScWriteofflistStartTime:(NSString *)startTime
                        endTime:(NSString *)endTime
                        curPage:(NSInteger)curPage
                       pageSize:(NSInteger)pageSize
                        Success:(void(^)(NSDictionary *data))success
                        failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"startTime":startTime,
                             @"endTime":endTime,
                             @"curPage":[NSString stringWithFormat:@"%@",@(curPage)],
                             @"pageSize":[NSString stringWithFormat:@"%@",@(pageSize)]};
    [SCApiTool ZYGet:@"business/ordercode/writeofflist"
          parameters:parmes
       netIdentifier:[NSString stringWithFormat:@"business/ordercode/writeofflist%d",rand()]
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 生成二维码链接
+ (void)ScGenerateSuccess:(void(^)(NSDictionary *dic))success
                  failure:(void (^)(NSString *errormsg))fail{
    
    [SCApiTool ZYGet:@"business/qrcode/generate"
       netIdentifier:[NSString stringWithFormat:@"business/qrcode/generate%d",rand()]
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 劵码核销
+ (void)ScWriteoffOrdercode:(NSArray *)ordercode
                    success:(void(^)(NSDictionary *dic))success
                    failure:(void (^)(NSString *errormsg))fail{
    
    NSDictionary *parmes = @{@"ordercode":ordercode};
    [SCApiTool ZYPost:@"business/ordercode/writeoff"
           parameters:parmes
        netIdentifier:@"business/ordercode/writeoff"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.data);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}

#pragma mark 扫描二维码核销
+ (void)ScScanUrl:(NSString *)url
          success:(void(^)(NSDictionary *dic))success
              failure:(void (^)(NSString *errormsg))fail{
    
    [SCApiTool ZYScanCodeGet:url
                  parameters:nil
       netIdentifier:@"scan"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 扫码  授权码
+ (void)ScSscanauthcode:(NSString *)url
                success:(void(^)(NSString *msg))success
                failure:(void (^)(NSString *errormsg))fail{
    SCUser *user = [SCUserTool loadInfo];
    NSDictionary *parmes = @{@"member_token":user.token};
    [SCApiTool ZYScanCodeGet:url
                  parameters:parmes
               netIdentifier:@"scanauthcode"
                    progress:nil
                     success:^(ZYJsonData *data) {
                         success(data.msg);
                     } failure:^(NSString *msg) {
                         fail(msg);
                     }];
}


#pragma mark 我的店员
+ (void)ScMemberlistSuccess:(void(^)(NSArray *data))success
                    failure:(void (^)(NSString *errormsg))fail{
    [SCApiTool ZYGet:@"business/shopstore/memberlist"
       netIdentifier:[NSString stringWithFormat:@"business/shopstore/memberlist%d",rand()]
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.data);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 新增店员
+ (void)ScMemberjoinMember_id:(NSString *)Member_id
                      success:(void(^)(NSString *msg))success
                      failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"Member_id":Member_id};
    [SCApiTool ZYPost:@"store/memberjoin"
           parameters:parmes
        netIdentifier:@"store/memberjoin"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}

#pragma mark 删除店员
+ (void)ScMemberdestoryMember_id:(NSString *)member_id
                         success:(void(^)(NSString *msg))success
                         failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"member_id":member_id};
    [SCApiTool ZYPost:@"business/shopstore/memberdestory"
           parameters:parmes
        netIdentifier:@"business/shopstore/memberdestory"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}



#pragma mark 扫码-授权码
+ (void)ScScanauthcodeStoreId:(NSString *)storeId
                      success:(void(^)(NSString *msg))success
                      failure:(void (^)(NSString *errormsg))fail{
    
    NSDictionary *parmes = @{@"store_id":storeId,
                             @"member_token":[SCUserTool loadInfo].token};
    [SCApiTool ZYGet:@"qrcode/scanauthcode"
          parameters:parmes
       netIdentifier:@"qrcode/scanauthcode"
            progress:nil
             success:^(ZYJsonData *data) {
                 success(data.msg);
             } failure:^(NSString *msg) {
                 fail(msg);
             }];
}

#pragma mark 使用授权码新增店员
+ (void)ScauthcodetomemberAuth_code:(NSString *)auth_code
                            success:(void(^)(NSString *msg))success
                            failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"auth_code":auth_code};
    [SCApiTool ZYPost:@"business/qrcode/authcodetomember"
           parameters:parmes
        netIdentifier:@"business/qrcode/authcodetomember"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}

#pragma mark 忘记密码
+ (void)ScForgotpasswordPhone:(NSString *)phone
                         code:(NSString *)code
                     password:(NSString *)password
                      success:(void(^)(NSString *msg))success
                      failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"phone":phone,
                             @"code":code,
                             @"password":password};
    [SCApiTool ZYPost:@"business/auth/forgotpassword"
           parameters:parmes
        netIdentifier:@"business/auth/forgotpassword"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}
#pragma mark 绑定手机
+ (void)ScRevisemobilePhone:(NSString *)phone
                       code:(NSString *)code
                    success:(void(^)(NSString *msg))success
                    failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{@"phone":phone,
                             @"code":code};
    [SCApiTool ZYPost:@"business/auth/revisemobile"
           parameters:parmes
        netIdentifier:@"business/auth/revisemobile"
             progress:nil
              success:^(ZYJsonData *data) {
                  success(data.msg);
              } failure:^(NSString *msg) {
                  fail(msg);
              }];
}
#pragma mark 可结算单明细
+ (void)ScEnableCurPage:(NSInteger )curPage
               pageSize:(NSInteger )pageSize
                success:(void(^)(NSDictionary *dic))success
                failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{ @"curPage":[NSString stringWithFormat:@"%@",@(curPage)],
                              @"pageSize":[NSString stringWithFormat:@"%@",@(pageSize)]};
    [SCApiTool ZYVersionPost:@"business/bill/enable"
                      Accept:@"v1s1"
                  parameters:parmes
               netIdentifier:@"business/bill/enable"
                    progress:nil
                     success:^(ZYJsonData *data) {
                         success(data.data);
                     } failure:^(NSString *msg) {
                          fail(msg);
                     }];
}

#pragma mark 历史结算单
+ (void)ScBillStartTime:(NSString *)startTime
                endTime:(NSString *)endTime
                CurPage:(NSInteger )curPage
               pageSize:(NSInteger )pageSize
                success:(void(^)(NSDictionary *dic))success
                failure:(void (^)(NSString *errormsg))fail{
    
    NSDictionary *parmes = @{@"startTime":startTime,
                             @"endTime":endTime,
                             @"curPage":[NSString stringWithFormat:@"%@",@(curPage)],
                             @"pageSize":[NSString stringWithFormat:@"%@",@(pageSize)]};
    [SCApiTool ZYVersionPost:@"business/bill/bill"
                      Accept:@"v1s1"
                  parameters:parmes
               netIdentifier:@"business/bill/bill"
                    progress:nil
                     success:^(ZYJsonData *data) {
                         success(data.data);
                     } failure:^(NSString *msg) {
                         fail(msg);
                     }];
}
#pragma mark 申请结算
+ (void)ScApplySuccess:(void(^)(NSString *msg))success
               failure:(void (^)(NSString *errormsg))fail{
    
    [SCApiTool ZYVersionPost:@"business/bill/apply"
                      Accept:@"v1s1"
                  parameters:nil
               netIdentifier:@"business/bill/apply"
                    progress:nil
                     success:^(ZYJsonData *data) {
                         success(data.msg);
                     } failure:^(NSString *msg) {
                         fail(msg);
                     }];
}
#pragma mark 结算单明细
+ (void)Scdetailbill_id:(NSString *)bill_id
                   Page:(NSInteger )curPage
               pageSize:(NSInteger )pageSize
                success:(void(^)(NSDictionary *dic))success
                failure:(void (^)(NSString *errormsg))fail{
    NSDictionary *parmes = @{ @"curPage":[NSString stringWithFormat:@"%@",@(curPage)],
                              @"pageSize":[NSString stringWithFormat:@"%@",@(pageSize)],
                              @"bill_id":bill_id
                              };
    [SCApiTool ZYVersionPost:@"business/bill/detail"
                      Accept:@"v1s1"
                  parameters:parmes
               netIdentifier:@"business/bill/detail"
                    progress:nil
                     success:^(ZYJsonData *data) {
                         success(data.data);
                     } failure:^(NSString *msg) {
                         fail(msg);
                     }];
}




@end
